home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 5
/
The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO
/
amiga
/
snapf20.lha
/
SnapFiles.spot
< prev
Wrap
Text File
|
1994-05-22
|
11KB
|
437 lines
/* SnapFiles V2.0 By Glenn Wihlborg (2:200/600.39@Fidonet)
* Tries to find possible filenames in messages.
* $VER: SnapFiles 2.0 (22-MAY-94)
* SnapFiles is offered to you under the concepts of Netmailware. That means
if you are using this in a period of 30 days, I would lika a Netmail
from you :):):):)
* NOTICE!! You must have T: assigned to somewhere in your system */
IF ~SHOW(Libraries,'rexxsupport.library') THEN
IF ~ADDLIB("rexxsupport.library",0,-30,0) THEN DO
EXIT
END
ADDRESS Spot
OPTIONS Results
SIGNAL ON BREAK_C
SIGNAL ON SYNTAX
SIGNAL ON FAILURE
Ver = '2.0' /* Current version of SnapFiles */
TagNames. = ""
TagCounter = 0
/* Fill in these three variables so they fit your system */
PathName = 'Outbound:' /* Path to your outbound dir, Must end with ':' or '/' */
TempDir = 'T:SnapFilelist' /* Path to the tempfile */
RexxReq = 1 /* If you have rexxreqtools.library
installed, set this to 1 otherwise 0 */
IF RexxReq == 1 THEN DO
Foo = ADDLIB("rexxreqtools.library",0,-30,0)
END
CR ='0d'x /* Carridge return */
LF ='0a'x /* Line feed */
AP ='27'x /* Is Ascii 39 */
CO ='2C'x /* Is Ascii 44 */
FileHit = 0 /* If there are possible files this will be set to one */
FileLen = 0 /* Length of temporary file, used with progressupdate */
LineLen = 0 /* Length of one line in temp file, used with progressupdate */
Twice = 0 /* Counter for dupe filename */
Total = 0 /* Total files found */
NumExt = 10 /* Total extensions to search for */
Ext.1 = ".LHA" /* Predefined extensions */
Ext.2 = ".ZIP" /* If you add or remove extensions */
Ext.3 = ".LZH" /* you MUST change the 'NumExt' variable to the */
Ext.4 = ".ARJ" /* right value */
Ext.5 = ".ZOO"
Ext.6 = ".DMS"
Ext.7 = ".ARC"
Ext.8 = ".EXE"
Ext.9 = ".ADS"
EXT.10 = ".GIF"
'ismessages' /* Are we in messages? */
IF RC>0 THEN DO
Note = 'Use in message window only!'
CALL Notify()
EXIT
END
'lockgui'
'getfromaddress'
From = Result
'requestresponse TITLE "SnapFiles 'Ver'" PROMPT "Use Which Nodenumber?"
CENTER GADGETS _From|_Boss|_Other|_Cancel'
IF RC = 0 THEN DO
'unlockgui'
EXIT
END
/* Strip from address e.g. 2:200/600.39 to 2.200.600.39 */
IF RC = 1 THEN DO
Zon = LEFT(From,POS(':',From)-1)
From = DELSTR(From,1,POS(':',From))
Net = LEFT(From,POS('/',From)-1)
From = DELSTR(From,1,POS('/',From))
Node = From
OutReq = PathName||Zon||.||Net||.||Node||'.Req'
CALL Start()
END
/* Strip from address to boss address e.g. 2:200/600.39 to 2.200.600.0 */
IF RC = 2 THEN DO
Zon = LEFT(From,POS(':',From)-1)
From = DELSTR(From,1,POS(':',From))
Net = LEFT(From,POS('/',From)-1)
From = DELSTR(From,1,POS('/',From))
Node = LEFT(From,POS('.',From))
OutReq = PathName||Zon||.||Net||.||Node||0||'.Req'
CALL Start()
END
/* Use another nodenumber */
IF RC = 3 THEN DO
'requeststring TITLE "New Nodenumber" PROMPT "Format: Z:N/N.P or Z.N.N.P"'
Other = Result
IF RC=5 | RC=0 & Other == '' THEN DO
'unlockgui'
EXIT
END
IF POS('.',Other) ~= LASTPOS('.',Other) THEN DO
OutReq = PathName||Other||'.Req'
CALL Start()
END
Zon = LEFT(Other,POS(':',Other)-1)
Other = DELSTR(Other,1,POS(':',Other))
Net = LEFT(Other,POS('/',Other)-1)
Other = DELSTR(Other,1,POS('/',Other))
Node = Other
OutReq = PathName||Zon||.||Net||.||Node||'.Req'
CALL Start()
END
Start:
'saveascii TO "T:SnapFiles.tmp" OVERWRITE NOHEADER NOKLUDGES NOTEARLINE NOORIGIN'
IF ~OPEN('Input','T:SnapFiles.tmp', 'READ') THEN DO /* Temp file */
Note = 'Unable to open T:SnapFiles.tmp'
CALL Notify()
'unlockgui'
EXIT
END
ELSE
FileLen = WORD(STATEF("T:SnapFiles.tmp"),2) /* Get size of file */
'progressopen TITLE "SnapFiles 'Ver'"
PROMPT "Scanning, Found 'Total' : Dupes 'Twice'"'
Prequest = Result
StartTime = TIME('R') /* Start timer */
DO WHILE ~EOF('Input')
Line = READLN('Input')
LineLen = LENGTH(Line)
FileLen = FileLen - LineLen
ElapTime = TIME('E')
'progressupdate PROMPT "Elapsed 'ElapTime' s : Found 'Total' : Dupes 'Twice'"' Prequest LineLen FileLen
IF RC = 5 THEN DO
CALL BailOut()
END
DO x = 1 to WORDS(Line)
Hit = WORD(Line,x)
WordPos = LASTPOS('.',Hit)
Extension = UPPER(RIGHT(Hit,4))
IF RIGHT(Hit,1) ~= '.' & WordPos < 1 THEN DO
NOP
END
ELSE
DO a = 1 to NumExt
IF UPPER(RIGHT(Hit,4)) == Ext.a THEN DO
CALL DoFileList()
LEAVE
END
LenHit = LENGTH(Hit)
LastChar = RIGHT(Hit,LenHit + 1 - LenHit)
Status = DATATYPE(LastChar,'A')
IF Status ~= 1 THEN DO
DO WHILE Status ~= 1
Len = ABS(LENGTH(Hit) - 1)
IF Len <= 1 THEN LEAVE
ELSE
Hit = LEFT(Hit,Len)
LenHit = LENGTH(Hit)
LastChar = RIGHT(Hit,LenHit - LenHit + 1)
IF POS('.',Hit) = 0 THEN LEAVE
ELSE
Status = DATATYPE(LastChar,'A')
END
END
LenHit = LENGTH(Hit)
FirstChar = LEFT(Hit,LenHit - LenHit + 1)
Status = DATATYPE(FirstChar,'A')
IF Status ~= 1 THEN DO
DO WHILE Status ~= 1
Len = ABS(LENGTH(Hit) - 1)
FirstChar = LEFT(Hit,LenHit - LenHit + 1)
IF Len <= 1 THEN LEAVE
ELSE
Hit = RIGHT(Hit,Len)
LenHit = LENGTH(Hit)
FirstChar = LEFT(Hit,LenHit - LenHit + 1)
Status = DATATYPE(FirstChar,'A')
END
END
IF POS('.',Hit) = 0 THEN LEAVE
ELSE
DO a = 1 to NumExt
IF UPPER(RIGHT(Hit,4)) == Ext.a THEN DO
CALL DoFileList()
LEAVE
END
END
LEAVE
END
END
END
'progressclose' Prequest
EndTime = TIME('E') /* Stop timer */
TotalTime = (EndTime - StartTime)
CALL CLOSE('Input')
address command 'delete >NIL: T:SnapFiles.tmp' /* Delete temp file */
'unlockgui'
IF FileHit ~= 1 THEN DO /* Did we find any filenames? */
Note = 'No Possible files!!'CR'Operation took 'TotalTime' Sec.'
CALL Notify()
EXIT
END
ELSE
Request = 'All done found 'Total' File(s)'CR''Twice' Duplicate Filenames.'CR'Operation took 'TotalTime' Sec.'
CALL Request()
DoFileList: /* Create filelist */
FileHit = 1 /* Found one or more files */
IF ~EXISTS(TempDir) THEN DO
ADDRESS COMMAND 'makedir >NIL: 'TempDir'' /* Make tempdir for file list */
END
Out = TempDir||'/'Hit
IF EXISTS(Out) THEN DO
Twice = Twice + 1
RETURN
END
ELSE
IF ~OPEN('List',Out,'W') THEN DO
Note = 'Can not create FileList: 'Out''
CALL Notify()
END
CALL WRITELN('List',Hit)
CALL CLOSE('List')
Total = Total + 1
RETURN
TagFile: /* Tag one or more files */
TagPath = TempDir
IF RexxReq == 1 THEN DO
CALL rtfilerequest(TagPath, , "Select files", , "rtfi_flags=freqf_multiselect" "rt_pubscrname=SPOT", Files)
IF Files == 0 THEN DO
ADDRESS COMMAND 'delete ALL >NIL: 'TempDir'' /* Delete all files */
EXIT
END
DO X = 1 TO Files.Count
IF ~OPEN('File',Files.X,'R') THEN DO
Note = 'Can NOT open Tagfile'
CALL Notify()
EXIT
END
Line = READLN('File')
CALL CLOSE('File')
Taged = Line
TagCounter = TagCounter + 1
TagNames.TagCounter = Taged
END
Files = SHOWDIR(TempDir,'F')
IF Files ~= '' THEN DO
ADDRESS COMMAND 'delete ALL >NIL: 'TempDir'' /* Delete all files */
IF TagCounter = 0 THEN EXIT
IF ~EXISTS(OutReq) THEN DO
IF ~OPEN('FileReq',OutReq,'W') THEN DO
Note = 'Can not create Req file: 'Out'.'
CALL Notify()
EXIT
END
END
CALL OPEN('FileReq',OutReq,'A')
DO I = 1 TO TagCounter
CALL WRITELN('FileReq',TagNames.I)
END
CALL CLOSE('FileReq')
RETURN
END
END
DO FOREVER
'requestfile TITLE "Tag File(s)" PATH 'TagPath''
GetFile = Result
IF RC=5 | RC=0 & GetFile == '' THEN LEAVE
IF ~OPEN('File',GetFile,'R') THEN DO
Note = 'Can NOT open Tagfile'
CALL Notify()
CALL TagFile()
END
Line = READLN('File')
CALL CLOSE('File')
Taged = Line
TagCounter = TagCounter + 1
TagNames.TagCounter = Taged
ADDRESS COMMAND 'delete >NIL: 'GetFile'' /* Delete file */
END
Files = SHOWDIR(TempDir,'F')
IF Files ~= '' THEN DO
ADDRESS COMMAND 'delete ALL >NIL: 'TempDir'' /* Delete all files */
END /* if there are any */
ADDRESS COMMAND 'delete >NIL: 'TempDir'' /* Delete tempdir */
IF TagCounter = 0 THEN EXIT
IF ~EXISTS(OutReq) THEN DO
IF ~OPEN('FileReq',OutReq,'W') THEN DO
Note = 'Can not create Req file: 'Out'.'
CALL Notify()
EXIT
END
END
CALL OPEN('FileReq',OutReq,'A')
DO I = 1 TO TagCounter
CALL WRITELN('FileReq',TagNames.I)
END
CALL CLOSE('FileReq')
RETURN
TagAll: /* Tag all files auotomaticly */
TagAllPath = TempDir
Files = SHOWDIR(TagAllPath,'F')
DO x = 1 TO WORDS(Files)
NameOfFile = WORD(Files,x)
In = TagAllPath||'/'NameOfFile
IF ~OPEN('File',In,'R') THEN DO
Note = 'Can not open tagfile'
CALL Notify()
END
Line = READLN('File')
CALL CLOSE('File')
Taged = Line
TagCounter = TagCounter + 1
TagNames.TagCounter = Taged
END
ADDRESS COMMAND 'delete ALL >NIL: 'TempDir'' /* Delete all files */
IF ~EXISTS(OutReq) THEN DO
IF ~OPEN('FileReq',OutReq,'W') THEN DO
Note = 'Can not create Req file: 'Out'.'
CALL Notify()
EXIT
END
END
CALL OPEN('FileReq',OutReq,'A')
DO I = 1 TO TagCounter
CALL WRITELN('FileReq',TagNames.I)
END
CALL CLOSE('FileReq')
RETURN
BailOut: /* --- If user stops the operation, check this --- */
'progressclose' Prequest
'unlockgui'
CALL CLOSE('Input')
ADDRESS COMMAND 'delete >NIL: T:SnapFiles.tmp' /* Delete temp file */
IF FileHit ~= 1 THEN DO /* Did we find any filenames ? */
Note = 'Bailing out!!'CR'Found No Possible file names.'
CALL Notify()
EXIT
END
ELSE
Request = 'Bailing out!!'CR'Possible File(s) 'Total'.'CR''Twice' Duplicate Filenames.'
CALL Request()
Notify:
'requestnotify PROMPT "'Note'" CENTER'
RETURN
Request:
'requestresponse TITLE "SnapFiles 'Ver'" PROMPT "'Request'"
CENTER GADGETS _Tag|_All|_Cancel'
IF RC = 0 THEN DO
ADDRESS COMMAND 'delete ALL >NIL: 'TempDir'' /* Delete all files */
EXIT
END
IF RC = 1 THEN DO
CALL TagFile()
'filerequest'
EXIT
END
IF RC = 2 THEN DO
CALL TagAll()
'filerequest'
EXIT
END
/* --- Error handler (Hopefully it will not be used :) ) --- */
BREAK_C:
SYNTAX:
FAILURE:
'progressclose' Prequest
'unlockgui'
Note = ''Errortext(RC) 'at line' SIGL''
CALL Notify()
EXIT
END